package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Wuzifenpei;
import com.ruoyi.system.service.IWuzifenpeiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资分配Controller
 * 
 * @author ruoyi
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/system/wuzifenpei")
public class WuzifenpeiController extends BaseController
{
    @Autowired
    private IWuzifenpeiService wuzifenpeiService;

    /**
     * 查询物资分配列表
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:list')")
    @GetMapping("/list")
    public TableDataInfo list(Wuzifenpei wuzifenpei)
    {
        startPage();
        List<Wuzifenpei> list = wuzifenpeiService.selectWuzifenpeiList(wuzifenpei);
        return getDataTable(list);
    }

    /**
     * 导出物资分配列表
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:export')")
    @Log(title = "物资分配", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Wuzifenpei wuzifenpei)
    {
        List<Wuzifenpei> list = wuzifenpeiService.selectWuzifenpeiList(wuzifenpei);
        ExcelUtil<Wuzifenpei> util = new ExcelUtil<Wuzifenpei>(Wuzifenpei.class);
        util.exportExcel(response, list, "物资分配数据");
    }

    /**
     * 获取物资分配详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wuzifenpeiService.selectWuzifenpeiById(id));
    }

    /**
     * 新增物资分配
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:add')")
    @Log(title = "物资分配", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wuzifenpei wuzifenpei)
    {
        return toAjax(wuzifenpeiService.insertWuzifenpei(wuzifenpei));
    }

    /**
     * 修改物资分配
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:edit')")
    @Log(title = "物资分配", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wuzifenpei wuzifenpei)
    {
        return toAjax(wuzifenpeiService.updateWuzifenpei(wuzifenpei));
    }

    /**
     * 删除物资分配
     */
    @PreAuthorize("@ss.hasPermi('system:wuzifenpei:remove')")
    @Log(title = "物资分配", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wuzifenpeiService.deleteWuzifenpeiByIds(ids));
    }
}
